/**
* SFONDI
**/
var tok = 'pk.eyJ1Ijoibm9yZGFpIiwiYSI6ImNrMWFyMG1hNDI5ZWozb3FqbDRuOGNweTkifQ.uiw5cwXwP4MIySTR7ILKIQ';
var crs_default = L.CRS.proj4js('EPSG:3857', '+proj=merc +lat_0=0 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
var _crs_default = new L.Proj.CRS(
'EPSG: 3857',
'+proj=merc +lat_0=0 +lon_0=0 +k=1 +x_0=0 +y_0=0 +a=6378137 +b=6378137 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs');
var attribution_OSM = 'GeoNue | © OpenStreetMap';
var attribution_ESRI = 'GeoNue | © ESRI';
var attribution_MAPBOX = 'GeoNue | © OpenStreetMap | ' + '© Mapbox';
var attribution_MAPBOX2 = 'GeoNue | ' + '© Mapbox';
var osm = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: attribution_OSM
});
var bw_old = L.tileLayer('https://{s}.www.toolserver.org/tiles/bw-mapnik/{z}/{x}/{y}.png', {
attribution: attribution_OSM
});
var bw = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, {
id: 'dark-v9',
attribution: attribution_MAPBOX
});
/* var esri = L.tileLayer('https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}', {
attribution: attribution_ESRI
});*/
var esri = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, {
id: 'satellite-v9',
attribution: attribution_MAPBOX2
});
/* var nordai = L.tileLayer('https://api.mapbox.com/styles/v1/nordai/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, {
id: 'cj4iij3hc34tv2rpeua2p5q83',
attribution: attribution_MAPBOX2
}); */
var gray = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, {
id: 'light-v9',
attribution: attribution_MAPBOX
});
var terrain = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, {
id: 'outdoors-v9',
attribution: attribution_MAPBOX
});
var street = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, {
id: 'streets-v9',
attribution: attribution_MAPBOX
});
var geography = L.tileLayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', {
id: 'mapbox.geography-class',
attribution: attribution_MAPBOX
});
/**
* SFONDI RAS
**/
var crs_RAS_Stradario = new L.Proj.CRS.TMS(
'EPSG:3003',
'+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +units=m +towgs84=-168.6,-34.0,38.6,-0.374,-0.679,-1.379,-9.48 +no_defs', [1159976, 4299800, 1570920, 4577800], {
resolutions: [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25, 0.125]
}
);
var RAS_Stradario = new L.Proj.TileLayer.TMS('http://webgis.regione.sardegna.it/tms/stradario_EPSG3003/{z}/{x}/{y}.png', crs_RAS_Stradario, {
maxZoom: 14,
minZoom: 2,
continuousWorld: true,
tms: true,
attribution: 'â“’ 2013 Regione Autonoma della Sardegna'
});
var crs_RAS_Ortofoto2008 = new L.Proj.CRS.TMS(
'EPSG:3003',
'+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +units=m +towgs84=-168.6,-34.0,38.6,-0.374,-0.679,-1.379,-9.48 +no_defs', [1425343.527, 4300509.945, 1570593.527, 4574254.445], {
resolutions: [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5, 0.25, 0.125]
}
);
var RAS_Ortofoto2008 = new L.Proj.TileLayer.TMS('http://webgis.regione.sardegna.it/tms/ortofoto2008_EPSG3003/{z}/{x}/{y}.jpg', crs_RAS_Ortofoto2008, {
maxZoom: 14,
minZoom: 2,
continuousWorld: true,
tms: true,
attribution: 'â“’ 2008 Regione Autonoma della Sardegna'
});
var crs_RAS_Ortofoto2006 = new L.Proj.CRS.TMS(
'EPSG:3003',
'+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=-1000 +ellps=intl +units=m +towgs84=-168.6,-34.0,38.6,-0.374,-0.679,-1.379,-9.48 +no_defs', [1422280, 4300042.99999999068677, 1570760, 4577639.99999999068677], {
resolutions: [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1, 0.5]
}
);
var RAS_Ortofoto2006 = new L.Proj.TileLayer.TMS('http://webgis.regione.sardegna.it/tms/ortofoto2006_EPSG3003/{z}/{x}/{y}.jpg', crs_RAS_Ortofoto2006, {
maxZoom: 12,
minZoom: 2,
continuousWorld: true,
tms: true,
attribution: 'â“’ 2006 Regione Autonoma della Sardegna'
});
var crs_RAS_Ortofoto2000 = new L.Proj.CRS.TMS(
'EPSG:3003',
'+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +units=m +towgs84=-168.6,-34.0,38.6,-0.374,-0.679,-1.379,-9.48 +no_defs', [1422279.15999999991618, 4299995.33000000007451, 1570756.15999999991618, 4577630.33000000007451], {
resolutions: [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]
}
);
var RAS_Ortofoto2000 = new L.Proj.TileLayer.TMS('http://webgis.regione.sardegna.it/tms/ortofoto2000_EPSG3003/{z}/{x}/{y}.jpg', crs_RAS_Ortofoto2000, {
maxZoom: 11,
minZoom: 2,
continuousWorld: true,
tms: true,
attribution: 'â“’ 2000 Regione Autonoma della Sardegna'
});
var crs_RAS_Ortofoto1954 = new L.Proj.CRS.TMS(
'EPSG:3003',
'+proj=tmerc +lat_0=0 +lon_0=9 +k=0.9996 +x_0=1500000 +y_0=0 +ellps=intl +units=m +towgs84=-168.6,-34.0,38.6,-0.374,-0.679,-1.379,-9.48 +no_defs', [1415120.5, 4279652.5, 1595120.5, 4578652.5], {
resolutions: [2048, 1024, 512, 256, 128, 64, 32, 16, 8, 4, 2, 1]
}
);
var RAS_Ortofoto1954 = new L.Proj.TileLayer.TMS('http://webgis.regione.sardegna.it/tms/ortofoto1954_EPSG3003/{z}/{x}/{y}.png', crs_RAS_Ortofoto1954, {
maxZoom: 11,
minZoom: 0,
continuousWorld: true,
tms: true,
attribution: 'â“’ 1954 Regione Autonoma della Sardegna'
});
var disp = "";
/**
* MAPPA PRINCIPALE
**/
var lat = "";
var lon = "";
var zoom = "";
var typeName = "";
var filename = "_";
var nameSearch = "";
var nameIcon = "";
var nameColor = "";
//var cql_filter = "";
var cql_filter = "";
var maxFeatures = "";
var wfs = "";
var geojson = "";
var fromto = "";
var bl = "bn";
var layers = "geonue:istat_pa_gis_v";
var styles = "";
var wms = "";
var info_wms = "true";
var title_wms = "";
var ctr_bl = "true";
var legend = "true";
var ctr_search = "";
var search_google = "true";
var noFitBounds = "true";
var id = "";
var latlong = [];
var ctrSearch, baselayer, opt_map = null;
switch (bl) {
case 'osm':
baselayer = osm;
opt_map = {
scrollWheelZoom: false,
zoomControl: false
};
break;
case 'bw':
baselayer = bw;
opt_map = {
scrollWheelZoom: false,
zoomControl: false
};
break;
case 'gray':
baselayer = gray;
opt_map = {
scrollWheelZoom: false,
zoomControl: false
};
break;
case 'esri':
baselayer = esri;
opt_map = {
scrollWheelZoom: false,
zoomControl: false
};
break;
case 'nordai':
baselayer = nordai;
opt_map = {
scrollWheelZoom: false,
zoomControl: false
};
break;
case 'terrain':
baselayer = terrain;
opt_map = {
scrollWheelZoom: false,
zoomControl: false
};
break;
case 'street':
baselayer = street;
opt_map = {
scrollWheelZoom: false,
zoomControl: false
};
break;
case 'geography':
baselayer = geography;
opt_map = {
scrollWheelZoom: false,
zoomControl: false
};
break;
case 'ras_strad':
baselayer = RAS_Stradario;
opt_map = {
scrollWheelZoom: false,
crs: crs_RAS_Stradario,
continuousWorld: true,
worldCopyJump: false,
zoomControl: false
};
break;
case 'ras_orto2008':
baselayer = RAS_Ortofoto2008;
opt_map = {
scrollWheelZoom: false,
crs: crs_RAS_Ortofoto2008,
continuousWorld: true,
worldCopyJump: false,
zoomControl: false
};
break;
case 'ras_orto2006':
baselayer = RAS_Ortofoto2006;
opt_map = {
scrollWheelZoom: false,
crs: crs_RAS_Ortofoto2006,
continuousWorld: true,
worldCopyJump: false,
zoomControl: false
};
break;
case 'ras_orto2000':
baselayer = RAS_Ortofoto2000;
opt_map = {
scrollWheelZoom: false,
crs: crs_RAS_Ortofoto2000,
continuousWorld: true,
worldCopyJump: false,
zoomControl: false
};
break;
case 'ras_orto1954':
baselayer = RAS_Ortofoto1954;
opt_map = {
scrollWheelZoom: false,
crs: crs_RAS_Ortofoto1954,
continuousWorld: true,
worldCopyJump: false,
zoomControl: false
};
break;
case 'random':
var sfondi = [osm,bw,gray,esri,nordai,terrain,street];
baselayer = sfondi[Math.floor(Math.random() * sfondi.length)];
opt_map = {
scrollWheelZoom: false,
zoomControl: false,
attributionControl: false
};
break;
default:
baselayer = gray;
opt_map = {
scrollWheelZoom: false,
zoomControl: false
};
}
var tag_map = "map";
if (disp == "doublemap")
tag_map = "map_doublemap";
var map = L.map(tag_map, opt_map).addLayer(baselayer);
var controlLoader = L.control.loader().addTo(map);
if (layers) {
if (wms) {
wms = "/mapstore/proxy/?url="+wms;
} else {
wms = "/geoserver/wms";
}
var layerWMS = L.tileLayer.wms(wms, {
layers: layers,
tiled: true,
transparent: true,
format: 'image/png',
styles: styles
});
if (info_wms) {
// Add an event handler for the map "click" event
map.on('contextmenu', function(e) {
controlLoader.show();
// Build the URL for a GetFeatureInfo
var url = getFeatureInfoUrl(
map,
layerWMS,
e.latlng, {
'info_format': 'application/json'
//'propertyName': 'nome,codiceist1'
}
);
// Send the request and create a popup showing the response
$.ajax({
type: "POST",
dataType: 'json',
async: false,
url: url,
// data: { data: JSON.stringify(data) },
success: function(data) {
var feature = data.features[0];
if (feature) {
var dataArray = new Array;
var dataArray1 = new Array;
var str = "";
for (var o in feature.properties) {
if (o != "bbox" && feature.properties[o]) {
if (!isNaN(feature.properties[o]))
var searchURL = -1;
else
var searchURL = feature.properties[o].search("http://");
if (searchURL > -1) { // URL SCHEDA
var url = 'link';
str += '' + o + ': ' + url + '
';
} else
str += '' + o + ': ' + feature.properties[o] + '
';
dataArray1.push(o);
dataArray.push(feature.properties[o]);
}
}
L.popup()
.setLatLng(e.latlng)
.setContent(L.Util.template(str, feature.properties))
.openOn(map);
} else {
L.popup()
.setLatLng(e.latlng)
.setContent("No data")
.openOn(map);
}
controlLoader.hide();
},
failure: function() {
alert("Error!");
}
});
});
}
layerWMS.addTo(map);
}
L.control.social({
default_text: "Guess where I am"
}).addTo(map);
if (typeName || geojson) {
var progress = document.getElementById('progress');
var progressBar = document.getElementById('progress-bar');
function updateProgressBar(processed, total, elapsed, layersArray) {
if (elapsed > 500) {
// if it takes more than a second to load, display the progress bar:
progress.style.display = 'block';
progressBar.style.width = Math.round(processed / total * 100) + '%';
}
if (processed === total) {
// all markers processed - hide the progress bar:
progress.style.display = 'none';
}
}
var markers = L.markerClusterGroup({
chunkedLoading: true,
chunkProgress: updateProgressBar
});
var geojsonLayer = new L.GeoJSON(null, {
onEachFeature: function(feature, layer) {
var text = '';
for (var event in feature.properties) {
var dataCopy = feature.properties[event];
if (event != "id" && dataCopy) {
if (!isNaN(dataCopy))
var searchURL = -1;
else
var searchURL = dataCopy.search("http://");
if (searchURL > -1) { // URL SCHEDA
var url = 'link';
text += '' + event + ': ' + url + '
';
} else if (nameSearch == event) { // TITOLO SCHEDA
text += '' + dataCopy + '
';
} else
text += '' + event + ': ' + dataCopy + '
';
if (nameIcon == event) { //ICONA
var icona = dataCopy.toLowerCase().replace(" ", "_").replace(" ", "_");
var color = feature.properties[nameColor].toLowerCase().replace(" ", "_").replace(" ", "_");
layer.setIcon(L.AwesomeMarkers.icon({
icon: icona,
prefix: 'icon',
markerColor: color + '_color'
}));
}
}
}
layer.bindPopup(text);
//layer.marker(geo, {icon: L.AwesomeMarkers.icon({icon: 'medkit', prefix: 'fa', markerColor: 'red'}) }).addTo(map);
}
});
function getJson(data) {
geojsonLayer.addData(data);
markers.addLayer(geojsonLayer);
map.addLayer(markers);
if (!noFitBounds) map.fitBounds(markers.getBounds());
if (lat)
map.setView(new L.LatLng(lat, lon), zoom);
if (!ctr_search) {
$.ajax({
type: "POST",
dataType: 'json',
async: false,
url: 'save_json.php?filename=' + filename,
data: {
data: JSON.stringify(data)
},
success: function() {},
failure: function() {
alert("Error!");
}
});
}
}
var req_cql_filter = '';
if (cql_filter)
req_cql_filter = "&cql_filter=" + cql_filter;
if (wfs) {
wfs = "/mapstore/proxy/?url=" + wfs + escape("?service=WFS&version=1.0.0&request=GetFeature&outputformat=json&maxFeatures=" + maxFeatures + "&srsName=EPSG:4326&typeName=" + typeName + (req_cql_filter ? req_cql_filter : ''));
wfs = wfs.replace(/%20/g, "%2520");
} else if (geojson) {
wfs = "/mapstore/proxy/?url=" + geojson;
} else {
wfs = "/geoserver/ows" + "?service=WFS&version=1.0.0&request=GetFeature&outputformat=json&maxFeatures=" + maxFeatures + "&srsName=EPSG:4326&typeName=" + typeName + (req_cql_filter ? req_cql_filter : '');
}
$.ajax({
url: wfs,
dataType: 'json',
jsonpCallback: 'json',
success: getJson
});
var baseMaps = {
"Black and White": bw,
"Gray scale": gray,
"Mapnik": osm,
"Terrain": terrain,
"Street": street,
"Geography": geography,
"Aerea": esri
};
if (layers) {
var overlayMaps = {
"Marker": markers,
"Layer": layerWMS
};
var control = L.control.layers(baseMaps, overlayMaps, {
position: 'topleft'
});
} else {
var overlayMaps = {
"Marker": markers
};
var control = L.control.layers(baseMaps, null, {
position: 'topleft'
});
}
if (ctr_bl)
control.addTo(map);
ctrSearch = new L.Control.Search({
url: "search.php?q={s}&filename=" + filename + "&nameSearch=" + nameSearch,
text: 'Cerca...',
markerLocation: false,
propertyName: nameSearch,
zoom: 18,
position: 'topleft'
})
if (!ctr_search)
map.addControl(ctrSearch);
} else if (fromto) {
const latlong = [];
var check = 0;
var geodesicpolyline = [];
var info_temp = null;
var element_temp = null;
var geojsonMarkerOptions = {
radius: 3,
fillColor: "#ff7800",
color: "#000",
weight: 0.5,
opacity: 1,
fillOpacity: 0.8
};
var geojsonLayer = new L.GeoJSON(null, {
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, geojsonMarkerOptions);
},
onEachFeature: function(feature, layer) {
layer.on({
mouseover: highlightFeature,
mouseout: resetHighlight,
click: whenClicked
});
}
});
map.addLayer(geojsonLayer);
function whenClicked(e) {
var layer = e.target;
info_temp = layer.feature.properties;
geodesicpolyline.forEach(removeGeodesicPolyline);
geodesicpolyline.push(L.geodesicPolyline(latlong[layer.feature.properties.id], {color: '#efb401', weight: 2, lineCap: 'round'}).addTo(map));
map.fitBounds(L.geodesicPolyline(latlong[layer.feature.properties.id], {color: '#efb401', weight: 2, lineCap: 'round'}));
}
function highlightFeature(e) {
var layer = e.target;
layer.setStyle({
radius: 8,
fillColor: "#ff7800",
color: "#000",
weight: 0.5,
opacity: 1,
fillOpacity: 0.8
});
if (!L.Browser.ie && !L.Browser.opera) {
layer.bringToFront();
}
info.update(layer.feature.properties);
element_temp = L.geodesicPolyline(latlong[layer.feature.properties.id], {color: '#d95b07', weight: 3, lineCap: 'round'});
element_temp.addTo(map)
}
function resetHighlight(e) {
var layer = e.target;
layer.setStyle({
radius: 3,
fillColor: "#ff7800",
color: "#000",
weight: 0.5,
opacity: 1,
fillOpacity: 0.8
});
info.update(info_temp);
map.removeLayer(element_temp);
}
function getJson(data) {
geojsonLayer.addData(data);
data.features.forEach(addArrayLatLng);
if (check++ == 1) {
if (id) {
var layer = null;
data.features.forEach(function(entry) {
if (id.toString() == entry.properties.id)
layer = entry
});
info_temp = layer.properties;
geodesicpolyline.push(L.geodesicPolyline(latlong[layer.properties.id], {color: '#efb401', weight: 2, lineCap: 'round'}).addTo(map));
map.fitBounds(L.geodesicPolyline(latlong[layer.properties.id], {color: '#efb401', weight: 2, lineCap: 'round'}));
info.update(layer.properties);
}
else
latlong.forEach(addGeodesicpolyline);
}
}
function removeGeodesicPolyline(element, index, array) {
map.removeLayer(element);
}
function addArrayLatLng(element, index, array) {
if (element.properties.id) {
if (latlong[element.properties.id])
latlong[element.properties.id].push([element.geometry.coordinates[1], element.geometry.coordinates[0]]);
else
latlong[element.properties.id] = [[element.geometry.coordinates[1], element.geometry.coordinates[0]]];
}
else {
latlong[index] = [[element.geometry.coordinates[1], element.geometry.coordinates[0]]];
}
}
function addGeodesicpolyline(element, index, array) {
geodesicpolyline.push(L.geodesicPolyline(element, {color: '#efb401', weight: 2, lineCap: 'round'}).addTo(map));
}
var ft = fromto.split(",");
ft.forEach(addElementsLayer);
function addElementsLayer(element, index, array) {
var gj = "https://umap.geonue.com/it/datalayer/"+element+"/";
// var url = "/geonueexplorer/proxy/?url=" + gj;
var url = "/mapstore/proxy/?url=" + gj;
$.ajax({
url: url,
dataType: 'json',
jsonpCallback: 'json',
success: getJson
});
}
var info = L.control();
info.onAdd = function (map) {
this._div = L.DomUtil.create('div', 'info'); // create a div with a class "info"
this.update();
return this._div;
};
// method that we will use to update the control based on feature properties passed
info.update = function (props) {
this._div.innerHTML = '
' + props.places + '
'+(props.description?'' + props.description + '
':'')+''+(props.post?'post |':'')+' permalink
' : 'Per le info vai sui punti'); }; info.addTo(map); $(document).keyup(function (e) { if (e.keyCode == 27) { latlong.forEach(addGeodesicpolyline); } }); } else{ if (lat) map.setView(new L.LatLng(lat, lon), zoom); else map.setView(new L.LatLng(42.019389, 11.661126), 6); var baseMaps = { "Black and White": bw, "Gray scale": gray, "OpenStreetMap": osm, "Terrain": terrain, "Street": street, "Geography": geography, "Aerea": esri }; if (layers) { var overlayMaps = { "Layer": layerWMS }; var control = L.control.layers(baseMaps, overlayMaps, { position: 'topleft' }); } else var control = L.control.layers(baseMaps, null, { position: 'topleft' }); if (ctr_bl) control.addTo(map); } if (search_google) { var geocoder = new google.maps.Geocoder(); function googleGeocoding(text, callResponse) { geocoder.geocode({ address: text }, callResponse); } function filterJSONCall(rawjson) { var json = {}, key, loc, disp = []; for (var i in rawjson) { key = rawjson[i].formatted_address; loc = L.latLng(rawjson[i].geometry.location.lat(), rawjson[i].geometry.location.lng()); json[key] = loc; //key,value format } return json; } /* map.addControl(new L.Control.Search({ callData: googleGeocoding, filterJSON: filterJSONCall, markerLocation: true, autoType: false, autoCollapse: true, minLength: 2, zoom: 10 }));*/ map.addControl( new L.Control.Search({ url: 'https://nominatim.openstreetmap.org/search?format=json&q={s}', jsonpParam: 'json_callback', propertyName: 'display_name', propertyLoc: ['lat','lon'], marker: L.circleMarker([0,0],{radius:30}), autoCollapse: true, autoType: false, minLength: 2 }) ); } new L.Control.Zoom({ position: 'bottomright' }).addTo(map); // add location control to global name space for testing only // on a production site, omit the "lc = "! lc = L.control.locate({ position: 'topleft', follow: true, strings: { title: "Fammi vedere dove sono", // title of the locate control popup: "Ti trovi nel raggio di {distance} {unit} da questo punto", // text to appear if user clicks on circle outsideMapBoundsMsg: "Ti trovi fuori dalla mappa" // default message for onLocationOutsideMapBounds } }).addTo(map); var hash = new L.Hash(map); if (bl != "random") { L.controlCredits({ position: 'bottomleft', image: "./img/logo_geonue.png", link: "https://www.geonue.com/", text: "by Nordai s.r.l." }).addTo(map); } else { $.ajax({ type: "POST", dataType: 'json', async: false, url: 'json/comuni.json', success: function(comuni) { var i = Math.floor(Math.random() * comuni.totalFeatures); map.setView(new L.LatLng(comuni.features[i].geometry.coordinates[1], comuni.features[i].geometry.coordinates[0]), 15); }, failure: function() { alert("Error!"); } }); } // if (roll) { map.on('startfollowing', function() { map.on('dragstart', lc.stopFollowing); }).on('stopfollowing', function() { map.off('dragstart', lc.stopFollowing); }); // } if (layers && legend) { var a_layers = new Array(); a_layers = layers.split(','); var uri = wms; uri += "?request=GetLegendGraphic&"; uri += "layer=" + a_layers[0] + "&"; if (styles) { uri += "style=" + styles + "&"; } uri += "transparent=true&"; uri += "format=image/png&"; uri += "legend_options=fontAntiAliasing:true;fontSize:11;fontName:Arial;forceLabels:on"; var wmsLegendControl = new L.Control.WMSLegend; wmsLegendControl.options.uri = uri; map.addControl(wmsLegendControl); // L.wmsLegend(uri,map); } if (disp) { /** * MAPPA DISPOSITIVO **/ // SFONDI var osm_disp = L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', { attribution: attribution_OSM }); var bw_disp = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, { id: 'dark-v9', attribution: attribution_MAPBOX }); var esri_disp = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, { id: 'satellite-v9', attribution: attribution_MAPBOX2 }); var nordai_disp = L.tileLayer('https://api.mapbox.com/styles/v1/nordai/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, { id: 'cj4iij3hc34tv2rpeua2p5q83', attribution: attribution_MAPBOX2 }); var gray_disp = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, { id: 'light-v9', attribution: attribution_MAPBOX }); var terrain_disp = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, { id: 'outdoors-v9', attribution: attribution_MAPBOX }); var street_disp = L.tileLayer('https://api.mapbox.com/styles/v1/mapbox/{id}/tiles/{z}/{x}/{y}?access_token=' + tok, { id: 'streets-v9', attribution: attribution_MAPBOX }); var geography_disp = L.tileLayer('https://{s}.tiles.mapbox.com/v3/{id}/{z}/{x}/{y}.png', { id: 'mapbox.geography-class', attribution: attribution_MAPBOX }); //SFONDI RAS var RAS_Stradario_disp = new L.Proj.TileLayer.TMS('http://webgis.regione.sardegna.it/tms/stradario_EPSG3003/{z}/{x}/{y}.png', crs_RAS_Stradario, { maxZoom: 15, minZoom: 0, continuousWorld: true, tms: true, attribution: 'â“’ Regione Autonoma della Sardegna' }); var RAS_Ortofoto2006_disp = new L.Proj.TileLayer.TMS('http://webgis.regione.sardegna.it/tms/ortofoto2006_EPSG3003/{z}/{x}/{y}.jpg', crs_RAS_Ortofoto2006, { maxZoom: 12, minZoom: 2, continuousWorld: true, tms: true, attribution: 'â“’ Regione Autonoma della Sardegna' }); var RAS_Ortofoto2008_disp = new L.Proj.TileLayer.TMS('http://webgis.regione.sardegna.it/tms/ortofoto2008_EPSG3003/{z}/{x}/{y}.jpg', crs_RAS_Ortofoto2008, { maxZoom: 14, minZoom: 2, continuousWorld: true, tms: true, attribution: 'â“’ 2008 Regione Autonoma della Sardegna' }); var RAS_Ortofoto2000_disp = new L.Proj.TileLayer.TMS('http://webgis.regione.sardegna.it/tms/ortofoto2000_EPSG3003/{z}/{x}/{y}.jpg', crs_RAS_Ortofoto2000, { maxZoom: 11, minZoom: 2, continuousWorld: true, tms: true, attribution: 'â“’ 2000 Regione Autonoma della Sardegna' }); var RAS_Ortofoto1954_disp = new L.Proj.TileLayer.TMS('http://webgis.regione.sardegna.it/tms/ortofoto1954_EPSG3003/{z}/{x}/{y}.png', crs_RAS_Ortofoto1954, { maxZoom: 11, minZoom: 2, continuousWorld: true, tms: true, attribution: 'â“’ Regione Autonoma della Sardegna' }); var lat_disp = ""; var lon_disp = ""; var zoom_disp = ""; var typeName_disp = ""; var nameIcon_disp = ""; var nameColor_disp = ""; var nameSearch_disp = ""; var cql_filter_disp = ""; var maxFeatures_disp = ""; var wfs_disp = ""; var bl_disp = ""; var layers_disp = ""; var styles_disp = ""; var wms_disp = ""; var info_wms_disp = ""; var legend_disp = ""; var ctr_bl_disp = ""; var search_google_disp = "info_wms_disp="; var baselayer_disp, opt_map_disp = null; switch (bl_disp) { case 'osm': baselayer_disp = osm_disp; opt_map_disp = { scrollWheelZoom: false, zoomControl: false, attributionControl: false }; break; case 'bw': baselayer_disp = bw_disp; opt_map_disp = { scrollWheelZoom: false, zoomControl: false, attributionControl: false }; break; case 'gray': baselayer_disp = gray_disp; opt_map_disp = { scrollWheelZoom: false, zoomControl: false, attributionControl: false }; break; case 'esri': baselayer_disp = esri_disp; opt_map_disp = { scrollWheelZoom: false, zoomControl: false, attributionControl: false }; break; case 'nordai': baselayer_disp = nordai_disp; opt_map_disp = { scrollWheelZoom: false, zoomControl: false, attributionControl: false }; break; case 'terrain': baselayer_disp = terrain_disp; opt_map_disp = { scrollWheelZoom: false, zoomControl: false, attributionControl: false }; break; case 'street': baselayer_disp = street_disp; opt_map_disp = { scrollWheelZoom: false, zoomControl: false, attributionControl: false }; break; case 'geography': baselayer_disp = geography_disp; opt_map_disp = { scrollWheelZoom: false, zoomControl: false, attributionControl: false }; break; case 'ras_strad': baselayer_disp = RAS_Stradario_disp; opt_map_disp = { scrollWheelZoom: false, crs: crs_RAS_Stradario, continuousWorld: true, worldCopyJump: false, zoomControl: false, attributionControl: false }; break; case 'ras_orto2006': baselayer_disp = RAS_Ortofoto2006_disp; opt_map_disp = { scrollWheelZoom: false, crs: crs_RAS_Ortofoto2006, continuousWorld: true, worldCopyJump: false, zoomControl: false, attributionControl: false }; break; case 'ras_orto2008': baselayer_disp = RAS_Ortofoto2008_disp; opt_map_disp = { scrollWheelZoom: false, crs: crs_RAS_Ortofoto2008, continuousWorld: true, worldCopyJump: false, zoomControl: false, attributionControl: false }; break; case 'ras_orto2000': baselayer_disp = RAS_Ortofoto2000_disp; opt_map_disp = { scrollWheelZoom: false, crs: crs_RAS_Ortofoto2006, continuousWorld: true, worldCopyJump: false, zoomControl: false, attributionControl: false }; break; case 'ras_orto1954': baselayer_disp = RAS_Ortofoto1954_disp; opt_map_disp = { scrollWheelZoom: false, crs: crs_RAS_Ortofoto1954, continuousWorld: true, worldCopyJump: false, zoomControl: false, attributionControl: false }; break; case 'random': var sfondi_disp = [osm_disp,bw_disp,gray_disp,esri_disp,nordai_disp,terrain_disp,street_disp]; baselayer_disp = sfondi_disp[Math.floor(Math.random() * sfondi_disp.length)]; opt_map_disp = { scrollWheelZoom: false, zoomControl: false, attributionControl: false }; break; default: baselayer_disp = gray_disp; opt_map_disp = { scrollWheelZoom: false, zoomControl: false, attributionControl: false }; } var map_disp = L.map('map_disp_' + disp, opt_map_disp).addLayer(baselayer_disp); var controlLoader_disp = L.control.loader().addTo(map_disp); if (layers_disp) { if (wms_disp) { // wms_disp = "/mapstore/proxy/?url="+wms; } else { wms_disp = "/geoserver/wms"; } var layerWMS_disp = L.tileLayer.wms(wms_disp, { layers: layers_disp, styles: styles_disp, tiled: true, format: 'image/png', transparent: true }); if (info_wms_disp) { // Add an event handler for the map "click" event map_disp.on('contextmenu', function(e) { controlLoader_disp.show(); // Build the URL for a GetFeatureInfo var url = getFeatureInfoUrl( map_disp, layerWMS_disp, e.latlng, { 'info_format': 'application/json' //'propertyName': 'nome,codiceist1' } ); // Send the request and create a popup showing the response $.ajax({ type: "POST", dataType: 'json', async: false, url: url, // data: { data: JSON.stringify(data) }, success: function(data) { var feature = data.features[0]; if (feature) { var dataArray = new Array; var dataArray1 = new Array; var str = ""; for (var o in feature.properties) { if (o != "bbox" && feature.properties[o]) { if (!isNaN(feature.properties[o])) var searchURL = -1; else var searchURL = feature.properties[o].search("http://"); if (searchURL > -1) { // URL SCHEDA var url = 'link'; str += '' + o + ': ' + url + '